package test;
import javax.sound.midi.*;
import javax.sound.midi.MidiDevice.Info;

public class Main 
{
	public static void main(String[] args) throws Exception
	{
		MidiDevice.Info[] systemInfo = getDevices();
		//MidiDevice uno = getUno(systemInfo);
		
		MidiDevice unoIn = MidiSystem.getMidiDevice(systemInfo[1]);
		MidiDevice unoOut = MidiSystem.getMidiDevice(systemInfo[2]);
		//unoIn.getDeviceInfo();
		//unoOut.getDeviceInfo();
		
		unoIn.open();
		unoOut.open();
		Receiver oneR = unoOut.getReceiver();
		Transmitter oneT = unoIn.getTransmitter();  
		ShortMessage message = new ShortMessage();
		message.setMessage(ShortMessage.CONTROL_CHANGE, 73, 89);
		oneR.send(message, -1);
	}

	private static MidiDevice getUno(Info[] info) {
		for(Info x : info)
		{
			if(x.getName().contains("Uno"))
			{
				try {
					return MidiSystem.getMidiDevice(x);
				} catch (MidiUnavailableException e) {
					e.printStackTrace();
				}
			}
		}
		return null;
	}

	private static Info[] getDevices() {
		return MidiSystem.getMidiDeviceInfo();
	}
}
